<!-- 路由 -->
// 导入组件
import Vue from "vue";
import Router from "vue-router";
// 登录
import login from "@/views/login";
// 注册
import register from "@/views/register";
// 首页
import index from "@/views/index";
//  首页概览
import thinking from "@/views/charts/thinking";
// 题库统计分析
import bankanalysis from "@/views/charts/bankanalysis";
//题库关联资源 
import resource from "@/views/resource/resource";
// 题库列表
import bank from "@/views/bank/bank";
//考核管理列表
import assessment from "@/views/assessment/assessmentList";
//考核结果列表
import assessmenanalysis from "@/views/assessment/assessmenanalysis";
//培训资源管理
import trainResources from "@/views/trainResources/trainResources";
/**
 * 系统管理
 */
// 用户管理
import user from "@/views/system/user";
// 角色管理
import Role from "@/views/system/Role";
// 启用路由
Vue.use(Router);
// 导出路由
export default new Router({
  routes: [
    {
      path: "/",
      name: "",
      component: login,
      hidden: true,
      meta: {
        requireAuth: false,
      },
    },
    {
      path: "/login",
      name: "登录",
      component: login,
      hidden: true,
      meta: {
        requireAuth: false,
      },
    },
    {
        path: "/register",
        name: "注册",
        component: register,
        hidden: true,
        meta: {
          requireAuth: false,
        },
      },
    {
      path: "/index",
      name: "首页",
      component: index,
      iconCls: "el-icon-tickets",
      children: [
        {
          path: "/charts/thinking",
          name: "首页",
          component: thinking,
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/charts/bankanalysis",
          name: "题库分析",
          component: bankanalysis,
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/bank/bank",
          name: "题库管理",
          component: bank,
          meta: {
            requireAuth: true,
          },
        },
        {
            path: "/resource/resource",
            name: "题库关联资源",
            component: resource,
            meta: {
              requireAuth: true,
            },
        },
        {
            path: "/assessment/assessmentList",
            name: "考核管理",
            component: assessment,
            meta: {
              requireAuth: true,
            },
        },
        {
            path: "/assessment/assessmenanalysis",
            name: "考核结果分析",
            component: assessmenanalysis,
            meta: {
              requireAuth: true,
            },
        },
        {
            path: "/trainResources/trainResources",
            name: "培训资源管理",
            component: trainResources,
            meta: {
              requireAuth: true,
            },
          },
        {
          path: "/system/Role",
          name: "角色管理",
          component: Role,
          meta: {
            requireAuth: true,
          },
        },
        {
          path: "/system/user",
          name: "用户管理",
          component: user,
          meta: {
            requireAuth: true,
          },
        },
      ],
    },
  ],
});
<!-- 首页 -->
<template>
  <div class="stbox">
    <!-- 面包屑导航 -->
    <div class="breadcrumb-title">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="thinking-content">
      <!-- 统计图 -->
      <div class="state-title">
        <div class="st-gbox" style="width:1000px;height: 500px;">
          <div class="cavasbox" ref="numberchart"></div>
        </div>
      </div>
      <!-- 动态 -->
      <div class="latest-updates-card">
        <h2>最新动态</h2>
        <ul>
          <li v-for="(update, index) in updates" :key="index">
            {{ update.title }} - {{ update.date }}
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
import Chart from 'echarts'
export default {
  name: "welcome",
  data() {
    return {
      machineNo: '',
      type: 'day',
      scores: [  
        { date: '2024-04-01', average: 82, max: 88, min: 76 },  
        { date: '2024-04-02', average: 84, max: 90, min: 78 },  
        { date: '2024-04-03', average: 85, max: 92, min: 79 },  
        { date: '2024-04-04', average: 83, max: 91, min: 77 },  
        { date: '2024-04-05', average: 86, max: 93, min: 80 },  
        { date: '2024-04-06', average: 87, max: 94, min: 81 },  
        { date: '2024-04-07', average: 88, max: 95, min: 82 },  
      ],
      updates:[
        { title: '新功能发布：智能病例分析', date: '2024-04-01' },  
        { title: '性能优化：提升系统响应速度', date: '2024-04-02' }, 
        { title: '开展培训活动，提升医师技能', date: '2024-04-05' },
      ],
    }
  },
  // 导入组件
  components: {
    // 点聚合组件
  },
  created() { },
  mounted() {
    this.getNumber()
  },
  // 里面的函数只有调用才会执行
  methods: {
    // 考核成绩变化
    getNumber() {
      let numbercollection= {
        tooltip: {
          trigger: 'item',
          formatter: "{a} <br/>{b}日 : {c}"
        },
        title: {
          text: '考核成绩变化',
        },
        //显示图列
        legend: {
          data: [{
            name: '平均成绩',
            icon: 'rect'
          },
          {
            name: '最高成绩',
            icon: 'rect'
          }, {
            name: '最低成绩',
            icon: 'rect'
          },
          ],
          type: 'plain',
          orient: 'horizontal',
          show: true //图例是否显示
        },
        grid: {
          left: 50,
          right: 10,
          // top: 30,
          bottom: 30,
          borderWidth: 1
        },
        xAxis: {
          type: 'category',
          data: this.scores.map(score => score.date),
          axisLine: {
            lineStyle: {
              color: "#999999",
              width: 1
            }
          },
          axisLabel: {
            margin: 14,
            height: 70,
            interval: 0,
            textStyle: {
              fontSize: 10,
              color: "#999999"
            }
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            lineStyle: {
              color: "#999999",
              width: 1
            }
          },
          axisLabel: {
            margin: 14,
            textStyle: {
              fontSize: 10,
              color: "#999999"
            }
          },
          min: 70, // 设置 Y 轴最小值  
          max: 100, // 设置 Y 轴最大值  
        },
        series: [{
          name: '平均成绩',
          type: 'line',
          barGap: 0,
          data: this.scores.map(score => score.average) ,
          barWidth: 10,
          type: "line",
          symbol: "square",
          symbolSize: 8,
          smooth: true,
          itemStyle: {
            normal: {
              color: "#008080",
              lineStyle: {
                color: "#008080",
              }
            }
          }
        }, {
          name: '最高成绩',
          data: this.scores.map(score => score.max),
          type: "line",
          symbol: "square",
          symbolSize: 8,
          smooth: true,
          itemStyle: {
            normal: {
              color: "#FF00FF",
              lineStyle: {
                color: "#FF00FF",
              }
            }
          }
        }, {
          name: '最低成绩',
          data: this.scores.map(score => score.min),
          type: "line",
          symbol: "square",
          symbolSize: 8,
          smooth: true,
          itemStyle: {
            normal: {
              color: "#FF7E2C",
              lineStyle: {
                color: "#FF7E2C",
              }
            }
          }
        },
        ]
      }
      this.chart = Chart.init(this.$refs.numberchart)
      this.chart.setOption(numbercollection)
    },
  }
};
</script>
<style>
.stbox {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
.stsearch {
  text-align: center;
}
.text-c {
  text-align: center;
}
.st-gbox {
  background-color: #fff;
  margin-top: 20px;
  border-radius: 5px;
  height: 30vh;
  box-sizing: border-box;
  padding: 10px;
}
.cavasbox {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}
.canvas{
  width: 100%;
  height: 100%;
}
.paybox {
  width: 100%;
  background-color: #fff;
  box-sizing: border-box;
  border-radius: 5px;
  margin-top: 20px;
  height: 32vh;
}
.breadcrumb-title {
  margin-top: 10px;
  margin-bottom: 10px;
}
.latest-updates-card {  
  background-color: #fff;  
  border: 1px solid #ddd;  
  border-radius: 5px;  
  padding: 20px;  
  margin-bottom: 20px;  
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);  
}  
.latest-updates-card h2 {  
  font-size: 18px;  
  margin-bottom: 15px;  
}  
.latest-updates-card ul {  
  list-style-type: none;  
  padding: 0;  
}  
.latest-updates-card li {  
  margin-bottom: 10px;  
} 
</style>
<!-- 登录 -->
<template>
  <div class="login-wrap">
    <el-form label-position="left" :model="userForm" :rules="rules" ref="userForm" label-width="0px" class="demo-userForm login-container">
      <h3 class="title">数字化手术室综合管理系统</h3>
      <el-form-item prop="username">
        <el-input type="text" v-model="userForm.username" auto-complete="off" placeholder="账号"></el-input>
      </el-form-item>
      <el-form-item prop="password">
        <el-input type="password" v-model="userForm.password" auto-complete="off" placeholder="密码"></el-input>
      </el-form-item>
      <el-checkbox class="remember" v-model="automatic">自动登录</el-checkbox>
      <el-form-item style="width:100%;margin:0 auto">
        <el-button type="primary" style="width:40%; margin-right: 30px;" @click="submitUser('userForm')" :loading="logining">登录</el-button>  
      </el-form-item>
    </el-form>
  </div>
</template>
<script type="text/ecmascript-6">
import { login } from '../api/userMG'
import { setCookie, getCookie, delCookie } from '../utils/util'
import md5 from 'js-md5'
export default {
  name: 'login',
  data() {
    return {
      //定义loading默认为false
      logining: false,
      // 记住密码
      automatic: false,
      userForm: {
        //username和password默认为空
        username: '',
        password: '',
        code: '',
        randomStr: '',
        codeimg: ''
      },
      //rules前端验证
      rules: {
        username: [{ required: true, message: '请输入账号', trigger: 'blur' }],
        password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
      },
      passwordVisible: false,
      passwordForm: {
        newPassword: "",
        confirmPassword: "",
      },
      passwordResetForm: {
        newPassword: "",
        confirmPassword: "",
      },
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    this.$message({
      message: '账号密码及验证码不为空即可',
      type: 'success'
    })
    // 获取图形验证码
    this.getcode()
    // 获取存在本地的用户名密码
    this.getpwd()
  },
  // 里面的函数只有调用才会执行
  methods: {
    // 获取用户名密码
    getpwd() {
      if (getCookie('user') != '' && getCookie('pwd') != '') {
        this.userForm.username = getCookie('user')
        this.userForm.password = getCookie('pwd')
        this.automatic = true
      }
    },
    //获取info列表
    submitUser(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          this.logining = true
          // 测试通道，不为空直接登录
          setTimeout(() => {
            this.logining = false
            this.$store.commit('login', 'true')
            this.$router.push({ path: '/surgical/surgical' })
          }, 1000)
          // 正式环境
          login(this.userForm).then(res => {
            if (res.success) {
              if (this.automatic) {
                //保存帐号到cookie，有效期7天
                setCookie('user', this.userForm.username, 7)
                //保存密码到cookie，有效期7天
                setCookie('pwd', this.userForm.password, 7)
              } else {
                delCookie('user')
                delCookie('pwd')
              }
              //如果请求成功就让他2秒跳转路由
              setTimeout(() => {
                this.logining = false
                // 缓存token
                localStorage.setItem('logintoken', res.data.token)
                // 缓存用户个人信息
                localStorage.setItem('userdata', JSON.stringify(res.data))
                this.$store.commit('login', 'true')
                this.$router.push({ path: '/bank/bank' })
              }, 1000)
            } else {
              this.$message.error(res.msg)
              this.logining = false
              return false
            }
          })
        } 
      })
    },
  }
}
</script>
<style scoped>
.login-wrap {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding-top: 10%;
  background-image: url('../../project/static/login1.jpg');
  background-repeat: no-repeat;
  background-position: center right;
  background-size: 100%;
}
.login-container {
  border-radius: 10px;
  margin: 0px auto;
  width: 350px;
  padding: 30px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  text-align: left;
  box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.1);
}
.title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}
.remember {
  margin: 0px 0px 35px 0px;
}
.code-box {
  text-align: right;
}
.codeimg {
  height: 40px;
}
</style>
<!-- 左边导航菜单 -->
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition  router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
        临床思维训练考核系统
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from '../api/userMG'
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      // 右侧标题
      data: [
      {
          menuid: 1,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '首页',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: 'icon-provider-manage',
              menuname: '首页',
              hasThird: 'N',
              url: 'charts/thinking',
              menus: null
            }
          ]
        },
        {
          menuid: 2,
          icon: 'li-icon-xiangmuguanli',
          menuname: '题库管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 22,
              icon: 'icon-cat-skuQuery',
              menuname: '题库列表',
              hasThird: 'N',
              url: 'bank/bank',
              menus: null
            },
            {
              menuid: 23,
              icon: 'icon-cat-skuQuery',
              menuname: '题库统计分析',
              hasThird: 'N',
              url: 'charts/bankanalysis',
              menus: null
            },
            {
              menuid: 24,
              icon: 'icon-cat-skuQuery',
              menuname: '题库关联资源',
              hasThird: 'N',
              url: 'resource/resource',
              menus: null
            }
          ]
        },
        {
          menuid: 3,
          icon: 'li-icon-dingdanguanli',
          menuname: '考核管理',
          hasThird: null,
          url: null,
          menus: [
          {
              menuid: 31,
              icon: 'icon-provider-manage',
              menuname: '考核管理',
              hasThird: 'N',
              url: 'assessment/assessmentList',
              menus: null
            },
            {
              menuid: 32,
              icon: 'icon-order-manage',
              menuname: '考核结果分析',
              hasThird: 'N',
              url: 'assessment/assessmenanalysis',
              menus: null
            },
          ]
        },
        {
          menuid: 4,
          icon: 'li-icon-dingdanguanli',
          menuname: '培训资源管理',
          hasThird: null,
          url: null,
          menus: [
          {
              menuid: 41,
              icon: 'icon-provider-manage',
              menuname: '培训资源管理',
              hasThird: 'N',
              url: 'trainResources/trainResources',
              menus: null
            },
          ]
        },
        {
          menuid: 5,
          icon: 'li-icon-xitongguanli',
          menuname: '系统管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 51,
              icon: 'icon-cus-manage',
              menuname: '用户管理',
              hasThird: 'N',
              url: 'system/user',
              menus: null
            },
            {
              menuid: 52,
              icon: 'icon-news-manage',
              menuname: '角色管理',
              hasThird: 'N',
              url: 'system/Role',
              menus: null
            },
          ]
        },
      ],
      msg: 'success'
    }
    this.allmenu = res.data
    //正式环境 调用接口
    menu(localStorage.getItem('logintoken'))
      .then(res => {
        console.log(JSON.stringify(res))
        if (res.success) {
          this.allmenu = res.data
        } else {
          this.$message.error(res.msg)
          return false
        }
      })
      .catch(err => {
        this.$message.error('数据加载失败，请稍后再试！')
      })
    // 监听
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
  background-color:rgba(2, 167, 240, 1) !important;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-submenu__title{
   background-color:rgba(2, 167, 240, 1) !important;
  color: white; 
}
.el-submenu__title i {
  color: white !important; 
}
.is-active{
  background-color:rgba(2, 167, 240, 1) !important;
  color: white !important;
}
.el-menu-bg {
  background-color: #1f2d3d ;
  background-color:rgba(2, 167, 240, 1) !important;
}
.el-menu-item{
  background-color:white !important;
  color: rgba(2, 167, 240, 1) !important;
}
.el-menu {
  border: none;
}
.el-submenu{
  background-color:rgba(2, 167, 240, 1) !important;
  color: white;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
  background-color:rgba(2, 167, 240, 1);
  color: white;
}
.logoimg {
  height: 40px;
}
</style>
<!-- 用户管理 -->
<template>
  <div>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="formInline" class="user-search">
      <el-form-item label="搜索：">
        <el-select size="small" v-model="formInline.isLock" placeholder="请选择">
          <el-option label="全部" value=""></el-option>
          <el-option label="正常" value="N"></el-option>
          <el-option label="已锁定" value="Y"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-input size="small" v-model="formInline.userName" placeholder="输入用户名"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
        <el-button size="small" type="primary" icon="el-icon-plus" @click="handleEdit()">添加</el-button>
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table size="small" @selection-change="selectChange" :data="userData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <el-table-column align="center" type="selection" width="50">
      </el-table-column>
      <el-table-column align="center" sortable prop="userName" label="用户名" width="120">
      </el-table-column>
      <el-table-column align="center" sortable prop="userRole" label="角色" width="120">
      </el-table-column>
      <el-table-column align="center" sortable prop="userMobile" label="手机号" width="120">
      </el-table-column>
      <el-table-column align="center" sortable prop="userSex" label="性别" min-width="50">
      </el-table-column>
      <el-table-column align="center" sortable prop="userEmail" label="邮件" min-width="120">
      </el-table-column>
      <el-table-column align="center" sortable prop="editTime" label="修改时间" min-width="120">
        <template slot-scope="scope">
          <div>{{scope.row.editTime}}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" sortable prop="isLock" label="状态" min-width="50">
        <template slot-scope="scope">
          <el-switch v-model="scope.row.isLock=='N'?nshow:fshow" active-color="#13ce66" inactive-color="#ff4949" @change="editType(scope.$index, scope.row)">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column align="center"  label="操作" width="300">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="deleteUser(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
    <!-- 编辑界面 -->
    <el-dialog :title="title" :visible.sync="editFormVisible" width="30%" @click='closeDialog("edit")'>
      <el-form label-width="80px" ref="editForm" :model="editForm" :rules="rules">
        <el-form-item label="用户名" prop="userName">
          <el-input size="small" v-model="editForm.userName" auto-complete="off" placeholder="请输入用户名"></el-input>
        </el-form-item>
        <el-form-item label="角色" prop="userRole">
          <el-input size="small" v-model="editForm.userRole" auto-complete="off" placeholder="请输入姓名"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="userMobile">
          <el-input size="small" v-model="editForm.userMobile" placeholder="请输入手机号"></el-input>
        </el-form-item>
        <el-form-item label="邮件" prop="userEmail">
          <el-input size="small" v-model="editForm.userEmail" placeholder="请输入邮箱地址"></el-input>
        </el-form-item>
        <el-form-item label="性别" prop="userSex">
          <el-radio v-model="editForm.userSex" label="男">男</el-radio>
          <el-radio v-model="editForm.userSex" label="女">女</el-radio>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click='closeDialog("edit")'>取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="submitForm('editForm')">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
// 导入请求方法
import {
  userList,
  userSave,
  userDelete,
  userPwd,
  userExpireToken,
  userFlashCache,
  userLock,
  UserDeptTree,
  UserDeptSave,
  UserDeptdeptTree,
  UserChangeDept
} from '../../api/userMG'
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      loading: false, //是显示加载
      title: '添加用户',
      editFormVisible: false, 
      dataAccessshow: false, 
      // 编辑与添加
      editForm: {
        userId: '',
        userName: '',
        userRole: '',
        roleId: '',
        userMobile: '',
        userEmail: '',
        userSex: '',
        token: localStorage.getItem('logintoken')
      },
      // 参数
      unitparm: {
        userIds: '',
        deptId: '',
        deptName: ''
      },
      // 选择数据
      selectdata: [],
      // rules表单验证
      rules: {
        userName: [
          { required: true, message: '请输入用户名', trigger: 'blur' }
        ],
        userRole: [
          { required: true, message: '请输入姓名', trigger: 'blur' }
        ],
        roleId: [{ required: true, message: '请选择角色', trigger: 'blur' }],
        userMobile: [
          { required: true, message: '请输入手机号', trigger: 'blur' },
          {
            pattern: /^1(3\d|47|5((?!4)\d)|7(0|1|[6-8])|8\d)\d{8,8}$/,
            required: true,
            message: '请输入正确的手机号',
            trigger: 'blur'
          }
        ],
        userEmail: [
          { required: true, message: '请输入邮箱', trigger: 'blur' },
          {
            pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
            required: true,
            message: '请输入正确的邮箱',
            trigger: 'blur'
          }
        ],
        userSex: [{ required: true, message: '请选择性别', trigger: 'blur' }]
      },
      // 删除用户
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      // 重置密码
      resetpsd: {
        userId: '',
        token: localStorage.getItem('logintoken')
      },
      // 用户下线
      offline: {
        token: localStorage.getItem('logintoken')
      },
      // 请求数据参数
      formInline: {
        page: 1,
        limit: 10,
        deptId: '',
        userName: '',
        userMobile: '',
        isLock: ''
      },
      //用户数据
      userData: [],
      // 数据权限
      UserDept: [],
      defaultProps: {
        children: 'children',
        label: 'name'
      },
      // 选中
      checkmenu: [],
      //参数role
      saveroleId: '',
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize:5,
        total:5
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  watch: {},
  created() {
    this.getdata(this.formInline)
  },
  methods: {
    // 获取数据方法
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      let res = {
        code: 0,
        msg: null,
        count:5,
        data: [
          {
            addUser: '1',
            editUser: '1',
            addTime: null,
            editTime: "2024年03月01日",
            userId: 1,
            systemNo: 'pmd',
            userName: 'admin',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRole: '高级管理员',
            userSex: '女',
            userMobile: '138-xxxx-xxxx',
            userEmail: '111@qq.com',
            isLock: 'N',
            deptId: 1,
            deptName: 'xxxx',
            roleId: 1
          },
          {
            addUser: '1',
            editUser: '1',
            addTime: null,
            editTime: "2024年03月17日",
            userId: 3,
            systemNo: 'mc',
            userName: 'test',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRole: '系统管理员',
            userSex: '男',
            userMobile: '186-xxxx-xxxx',
            userEmail: '222@qq.com',
            isLock: 'N',
            deptId: 2,
            deptName: 'xxxx',
            roleId: 101
          },
          {
            addUser: '1',
            editUser: '4',
            addTime: null,
            editTime: "2024年03月20日",
            userId: 4,
            systemNo: 'ec',
            userName: '茉莉',
            userPassword: '59ba8b7dda9ff79186311a5a9fa155ca',
            userRole: '用户',
            userSex: '女',
            userMobile: '134-xxxx-xxxx',
            userEmail: 'moli@test.com',
            isLock: 'N',
            deptId: 2,
            deptName: 'xxxx',
            roleId: 3
          },
          {
            addUser: null,
            editUser: null,
            addTime: 1526275128000,
            editTime: "2024年03月22日",
            userId: 28,
            systemNo: null,
            userName: '梦梦',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRole: '用户',
            userSex: '男',
            userMobile: '178-xxxx-xxxx',
            userEmail: 'mengmeng@qq.com',
            isLock: 'N',
            deptId: 4,
            deptName: 'zxxxxx',
            roleId: 1
          },
          {
            addUser: null,
            editUser: null,
            addTime: 1526275128000,
            editTime: "2024年03月01日",
            userId: 28,
            systemNo: null,
            userName: 'lisha',
            userPassword: 'e10adc3949ba59abbe56e057f20f883e',
            userRole: '用户',
            userSex: '女',
            userMobile: '176-xxxx-xxxx',
            userEmail: 'lisha@qq.com',
            isLock: 'N',
            deptId: 4,
            deptName: 'zxxxxx',
            roleId: 1
          },
        ]
      }
      this.loading = false
      this.userData = res.data
      // 分页赋值
      this.pageparm.currentPage = this.formInline.page
      this.pageparm.pageSize = this.formInline.limit
      this.pageparm.total = res.count
      // 测试环境  模拟数据结束  
      // 正式环境环境 调用接口
      // 获取用户列表
      userList(parameter).then(res => {
        this.loading = false
        if (res.success == false) {
          this.$message({
            type: 'info',
            message: res.msg
          })
        } else {
          this.userData = res.data
          // 分页赋值
          this.pageparm.currentPage = this.formInline.page
          this.pageparm.pageSize = this.formInline.limit
          this.pageparm.total = res.count
        }
      })
    },
    // 分页插件事件
    callFather(parm) {
      this.formInline.page = parm.currentPage
      this.formInline.limit = parm.pageSize
      this.getdata(this.formInline)
    },
    //搜索事件
    search() {
      this.getdata(this.formInline)
    },
    // 修改type
    editType: function(index, row) {
      this.loading = true
      let parm = {
        lock: '',
        userId: '',
        token: localStorage.getItem('logintoken')
      }
      parm.userId = row.userId
      let lock = row.isLock
      if (lock == 'N') {
        parm.lock = 'Y'
      } else {
        parm.lock = 'N'
      }
      // 修改状态
      userLock(parm).then(res => {
        this.loading = false
        if (res.success == false) {
          this.$message({
            type: 'info',
            message: res.msg
          })
        } else {
          this.$message({
            type: 'success',
            message: '状态修改成功'
          })
          this.getdata(this.formInline)
        }
      })
    },
    //显示编辑界面
    handleEdit: function(index, row) {
      this.editFormVisible = true
      if (row != undefined && row != 'undefined') {
        this.title = '修改用户'
        this.editForm.userId = row.userId
        this.editForm.userName = row.userName
        this.editForm.userRole = row.userRole
        this.editForm.roleId = row.roleId
        this.editForm.userMobile = row.userMobile
        this.editForm.userEmail = row.userEmail
        this.editForm.userSex = row.userSex
      } else {
        this.title = '添加用户'
        this.editForm.userId = ''
        this.editForm.userName = ''
        this.editForm.userRole = ''
        this.editForm.roleId = ''
        this.editForm.userMobile = ''
        this.editForm.userEmail = ''
        this.editForm.userSex = ''
      }
    },
    // 编辑、添加提交方法
    submitForm(editData) {
      this.$refs[editData].validate(valid => {
        if (valid) {
          // 请求方法
          userSave(this.editForm)
            .then(res => {
              this.editFormVisible = false
              this.loading = false
              if (res.success) {
                this.getdata(this.formInline)
                this.$message({
                  type: 'success',
                  message: '数据保存成功！'
                })
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.editFormVisible = false
              this.loading = false
              this.$message.error('保存失败，请稍后再试！')
            })
        } else {
          return false
        }
      })
    },
    handleClick(data, checked, node) {
      if (checked) {
        this.$refs.tree.setCheckedNodes([])
        this.$refs.tree.setCheckedNodes([data])
        this.unitparm.deptId = data.id
        this.unitparm.deptName = data.name
        //交叉点击节点
      } else {
      }
    },
=
    // 选择复选框事件
    selectChange(val) {
      this.selectdata = val
    },
    // 关闭编辑、增加弹出框
    closeDialog(dialog) {
      if (dialog == 'edit') {
        this.editFormVisible = false
      } else if (dialog == 'perm') {
        this.dataAccessshow = false
      } else if (dialog == 'unit') {
        this.unitAccessshow = false
      }
    },
    // 删除用户
    deleteUser(index, row) {
      this.$confirm('确定要删除吗?', '信息', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // 删除
          userDelete(row.id)
            .then(res => {
              if (res.success) {
                this.$message({
                  type: 'success',
                  message: '数据已删除!'
                })
                this.getdata(this.formInline)
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.loading = false
              this.$message.error('数据删除失败，请稍后再试！')
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除！'
          })
        })
    },
    //数据格式化
    changeArr(data) {
      var pos = {}
      var tree = []
      var i = 0
      while (data.length != 0) {
        if (data[i].pId == 0) {
          tree.push({
            id: data[i].id,
            name: data[i].name,
            pId: data[i].pId,
            open: data[i].open,
            checked: data[i].checked,
            children: []
          })
          pos[data[i].id] = [tree.length - 1]
          data.splice(i, 1)
          i--
        } else {
          var posArr = pos[data[i].pId]
          if (posArr != undefined) {
            var obj = tree[posArr[0]]
            for (var j = 1; j < posArr.length; j++) {
              obj = obj.children[posArr[j]]
            }
            obj.children.push({
              id: data[i].id,
              name: data[i].name,
              pId: data[i].pId,
              open: data[i].open,
              checked: data[i].checked,
              children: []
            })
            pos[data[i].id] = posArr.concat([obj.children.length - 1])
            data.splice(i, 1)
            i--
          }
        }
        i++
        if (i > data.length - 1) {
          i = 0
        }
      }
      return tree
    },
  }
}
</script>
<!-- 角色管理 -->
<template>
 <div>
   <!-- 搜索筛选 -->
   <el-form :inline="true" :model="formInline" class="user-search">
     <el-form-item label="搜索：">
       <el-input size="small" v-model="formInline.roleName" placeholder="输入角色名称"></el-input>
     </el-form-item>
     <el-form-item label="">
       <el-input size="small" v-model="formInline.roleNo" placeholder="输入角色代码"></el-input>
     </el-form-item>
     <el-form-item>
       <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
       <el-button size="small" type="primary" icon="el-icon-plus" @click="handleEdit()">添加</el-button>
     </el-form-item>
   </el-form>
   <!--列表-->
   <el-table size="small" :data="listData" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
     <el-table-column align="center" type="selection" width="60">
     </el-table-column>
     <el-table-column sortable prop="roleName" label="角色名称" width="300">
     </el-table-column>
     <el-table-column sortable prop="roleNo" label="角色代码" width="300">
     </el-table-column>
     <el-table-column sortable prop="editTime" label="修改时间" width="300">
       <template slot-scope="scope">
         <div>{{scope.row.editTime}}</div>
       </template>
     </el-table-column>
     <el-table-column sortable prop="editUser" label="修改人" width="300">
     </el-table-column>
     <el-table-column align="center" label="操作" min-width="300">
       <template slot-scope="scope">
         <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
         <el-button size="mini" type="danger" @click="deleteUser(scope.$index, scope.row)">删除</el-button>
       </template>
     </el-table-column>
   </el-table>
   <!-- 分页组件 -->
   <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
   <!-- 编辑界面 -->
   <el-dialog :title="title" :visible.sync="editFormVisible" width="30%" @click='closeDialog("edit")'>
     <el-form label-width="120px" :model="editForm" ref="editForm" :rules="rules">
       <el-form-item label="系统编码" prop="systemNo">
         <el-input size="small" v-model="editForm.systemNo" auto-complete="off" placeholder="请输入系统编码"></el-input>
       </el-form-item>
       <el-form-item label="角色名称" prop="roleName">
         <el-input size="small" v-model="editForm.roleName" auto-complete="off" placeholder="请输入角色名称"></el-input>
       </el-form-item>
       <el-form-item label="角色代码" prop="roleNo">
         <el-input size="small" v-model="editForm.roleNo" auto-complete="off" placeholder="请输入角色代码"></el-input>
       </el-form-item>
     </el-form>
     <div slot="footer" class="dialog-footer">
       <el-button size="small" @click='closeDialog("edit")'>取消</el-button>
       <el-button size="small" type="primary" :loading="loading" class="title" @click="submitForm('editForm')">保存</el-button>
     </div>
   </el-dialog>
 </div>
</template>
<script>
import {
 roleList,
 roleSave,
 roleDelete,
} from '../../api/userMG'
import Pagination from '../../components/Pagination'
export default {
 data() {
   return {
     nshow: true, //switch开启
     fshow: false, //switch关闭
     loading: false, //是显示加载
     editFormVisible: false, 
     menuAccessshow: false, 
     title: '添加',
     editForm: {
       roleId: '',
       systemNo: '',
       roleNo: '',
       roleName: '',
       token: localStorage.getItem('logintoken')
     },
     // rules 表单验证
     rules: {
       roleNo: [
         { required: true, message: '请输入角色代码', trigger: 'blur' }
       ],
       roleName: [
         { required: true, message: '请输入角色名称', trigger: 'blur' }
       ]
     },
     formInline: {
       page: 1,
       limit: 10,
       varLable: '',
       varName: '',
       token: localStorage.getItem('logintoken')
     },
     // 删除
     seletedata: {
       ids: '',
       token: localStorage.getItem('logintoken')
     },
     userparm: [], //搜索权限
     listData: [], //用户数据
     // 数据权限
     RoleRight: [],
     RoleRightProps: {
       children: 'children',
       label: 'name'
     },
     // 选中
     checkmenu: [],
     //参数role
     saveroleId: '',
     // 分页参数
     pageparm: {
       currentPage: 1,
       pageSize: 10,
       total: 10
     }
   }
 },
 // 注册组件
 components: {
   Pagination
 },
 watch: {},
 created() {
   this.getdata(this.formInline)
 },
 methods: {
   // 获取角色列表
   getdata(parameter) {
     // 模拟数据
     let res = {
       code: 0,
       msg: null,
       count: 6,
       data: [
         {
           addUser: 'root',
           editUser: 'root',
           addTime: 1519182004000,
           editTime: '2024年03月01日',
           roleId: 1,
           systemNo: 'pmd',
           roleNo: 'quan001',
           roleName: '高级管理员'
         },
         {
           addUser: null,
           editUser: null,
           addTime: 1521111376000,
           editTime:'2024年03月10日',
           roleId: 2,
           systemNo: 'order',
           roleNo: 'quan002',
           roleName: '系统管理员'
         },
         {
           addUser: null,
           editUser: null,
           addTime: 1520678221000,
           editTime: '2024年03月10日',
           roleId: 95,
           systemNo: 'pm',
           roleNo: 'quan003',
           roleName: '普通用户'
         },
       ]
     }
     this.loading = false
     this.listData = res.data
     // 分页赋值
     this.pageparm.currentPage = this.formInline.page
     this.pageparm.pageSize = this.formInline.limit
     this.pageparm.total = res.count
     // 测试环境  模拟数据结束  
     /***
      *  正式环境环境 调用接口
      */
     roleList(parameter)
       .then(res => {
         this.loading = false
         if (res.success == false) {
           this.$message({
             type: 'info',
             message: res.msg
           })
         } else {
           this.listData = res.data
           // 分页赋值
           this.pageparm.currentPage = this.formInline.page
           this.pageparm.pageSize = this.formInline.limit
           this.pageparm.total = res.count
         }
       })
       .catch(err => {
         this.loading = false
         this.$message.error('获取角色列表失败，请稍后再试！')
       })
   },
   // 分页插件事件
   callFather(parm) {
     this.formInline.page = parm.currentPage
     this.formInline.limit = parm.pageSize
     this.getdata(this.formInline)
   },
   // 搜索事件
   search() {
     this.getdata(this.formInline)
   },
   //显示编辑界面
   handleEdit: function(index, row) {
     this.editFormVisible = true
     if (row != undefined && row != 'undefined') {
       this.title = '修改'
       this.editForm.roleId = row.roleId
       this.editForm.systemNo = row.systemNo
       this.editForm.roleNo = row.roleNo
       this.editForm.roleName = row.roleName
     } else {
       this.title = '添加'
       this.editForm.roleId = ''
       this.editForm.systemNo = ''
       this.editForm.roleNo = ''
       this.editForm.roleName = ''
     }
   },
   // 编辑、增加页面保存方法
   submitForm(editData) {
     this.$refs[editData].validate(valid => {
       if (valid) {
         roleSave(this.editForm)
           .then(res => {
             this.editFormVisible = false
             this.loading = false
             if (res.success) {
               this.getdata(this.formInline)
               this.$message({
                 type: 'success',
                 message: '角色保存成功！'
               })
             } else {
               this.$message({
                 type: 'info',
                 message: res.msg
               })
             }
           })
           .catch(err => {
             this.editFormVisible = false
             this.loading = false
             this.$message.error('角色保存失败，请稍后再试！')
           })
       } else {
         return false
       }
     })
   },
   // 删除角色
   deleteUser(index, row) {
     this.$confirm('确定要删除吗?', '信息', {
       confirmButtonText: '确定',
       cancelButtonText: '取消',
       type: 'warning'
     })
       .then(() => {
         roleDelete(row.roleId)
           .then(res => {
             if (res.success) {
               this.$message({
                 type: 'success',
                 message: '角色已删除！'
               })
               this.getdata(this.formInline)
             } else {
               this.$message({
                 type: 'info',
                 message: res.msg
               })
             }
           })
           .catch(err => {
             this.loading = false
             this.$message.error('角色删除失败，请稍后再试！')
           })
       })
       .catch(() => {
         this.$message({
           type: 'info',
           message: '已取消删除'
         })
       })
   },
 }
}
</script>
<!-- 题库列表 -->
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: 'bank/bank' }">题库管理</el-breadcrumb-item>
      <el-breadcrumb-item>题库列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="questionInline" class="surgery-search">
      <el-form-item label="搜索：">
        <el-input size="small" v-model="questionInline.roomNumber" placeholder="输入题库名称"></el-input>
      </el-form-item>
      <el-form-item label="">
        <el-input size="small" v-model="questionInline.deptNo" placeholder="请输入题库编号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
        <el-button size="small" type="primary" icon="el-icon-plus" @click="questionEdit()">新增</el-button>
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table size="small" :data="questionBankList" highlight-current-row v-loading="loading" border
      element-loading-text="拼命加载中" style="width: 95.2%;">
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column align="center" prop="questionBankId" label="题库编号" width="200">
      </el-table-column>
      <el-table-column align="center" prop="questionBankName" label="题库名称" width="200">
      </el-table-column>
      <el-table-column align="center" prop="questionType" label="题型" width="100">
      </el-table-column>
      <el-table-column align="center" prop="quantity" label="数量" width="100">
      </el-table-column>
      <el-table-column align="center" prop="difficultyLevel" label="难度等级" width="200">
      </el-table-column>
      <el-table-column align="center" prop="usageFrequency" label="使用频率" width="200">
      </el-table-column>
      <el-table-column align="center" prop="updateTime" label="更新时间" width="260">
        <template slot-scope="scope">
          <div>{{ scope.row.updateTime }}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="操作" width="200">
        <template slot-scope="scope">
          <el-button size="mini" @click="questionEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="deletequestion(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
    <!-- 编辑界面 -->
    <el-dialog :title="title" :visible.sync="questionVisible" width="30%" @click="closeDialog">
      <el-form label-width="120px" :model="question" :rules="questionRules" ref="question">
        <el-form-item label="题库编号" prop="questionBankId">
          <el-input size="small" v-model="question.questionBankId" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="题库名称" prop="questionBankName">
          <el-input size="small" v-model="question.questionBankName" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="题型" prop="questionType">
          <el-input size="small" v-model="question.questionType" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="数量" prop="quantity">
          <el-input size="small" v-model="question.quantity" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="难度等级" prop="difficultyLevel">
          <el-input size="small" v-model="question.difficultyLevel" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="使用频率" prop="usageFrequency">
          <el-input size="small" v-model="question.usageFrequency" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="更新时间" prop="updateTime">
          <el-input size="small" v-model="question.updateTime" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title"
          @click="submitForm('question')">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { surgeryRoom, deptSave, questionDelete } from '../../api/basisMG'
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      nshow: true, //switch开启
      fshow: false, //switch关闭
      loading: false, //是显示加载
      questionVisible: false, //控制编辑页面显示与隐藏
      title: '添加',
      question: {
        date: '',
        questionBankId: '',
        questionBankName: '',
        questionType: '',
        quantity: 0,
        difficultyLevel: '',
        usageFrequency: '',
        updateTime: '',
        token: localStorage.getItem('logintoken')
      },
      // questionRules表单验证
      questionRules: {
        questionBankName: [
          { required: true, message: '请输入题库名称', trigger: 'blur' }
        ],
        questionBankId: [{ required: true, message: '请输入题库编号', trigger: 'blur' }],
        questionType: [{ required: true, message: '请输入题型', trigger: 'blur' }]
      },
      questionInline: {
        page: 1,
        limit: 10,
        token: localStorage.getItem('logintoken')
      },
      // 删除部门
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      questionBankList: [], //题库数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  created() {
    this.getdata(this.questionInline)
  },
  methods: {
    // 获取数据列表
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      let res = {
        code: 0,
        msg: null,
        count: 23,
        data:  [
          {
            date: '2024-04-01',
            questionBankId: 'T001',
            questionBankName: '呼吸系统题库',
            questionType: '单选题',
            quantity: 50,
            difficultyLevel: '中等',
            usageFrequency: '高',
            updateTime: '2024-03-30'
          },
          {
            date: '2024-04-02',
            questionBankId: 'T002',
            questionBankName: '消化系统题库',
            questionType: '多选题',
            quantity: 40,
            difficultyLevel: '困难',
            usageFrequency: '中',
            updateTime: '2024-03-28'
          },
          {
            date: '2024-04-03',
            questionBankId: 'T003',
            questionBankName: '心血管系统题库',
            questionType: '填空题',
            quantity: 30,
            difficultyLevel: '简单',
            usageFrequency: '高',
            updateTime: '2024-04-01'
          },
          {
            date: '2024-04-04',
            questionBankId: 'T004',
            questionBankName: '神经系统题库',
            questionType: '案例分析',
            quantity: 20,
            difficultyLevel: '中等',
            usageFrequency: '中',
            updateTime: '2024-03-31'
          },
          {
            date: '2024-04-05',
            questionBankId: 'T005',
            questionBankName: '内分泌系统题库',
            questionType: '判断题',
            quantity: 60,
            difficultyLevel: '困难',
            usageFrequency: '低',
            updateTime: '2024-04-02'
          },
          {
            date: '2024-04-06',
            questionBankId: 'T006',
            questionBankName: '泌尿系统题库',
            questionType: '简答题',
            quantity: 45,
            difficultyLevel: '简单',
            usageFrequency: '高',
            updateTime: '2024-04-04'
          },
          {
            date: '2024-04-07',
            questionBankId: 'T007',
            questionBankName: '外科常见疾病题库',
            questionType: '论述题',
            quantity: 25,
            difficultyLevel: '中等',
            usageFrequency: '中',
            updateTime: '2024-04-05'
          },
          {
            date: '2024-04-08',
            questionBankId: 'T008',
            questionBankName: '妇产科题库',
            questionType: '图表分析',
            quantity: 35,
            difficultyLevel: '困难',
            usageFrequency: '低',
            updateTime: '2024-04-06'
          },
          {
            date: '2024-04-09',
            questionBankId: 'T009',
            questionBankName: '儿科题库',
            questionType: '病例分析',
            quantity: 55,
            difficultyLevel: '简单',
            usageFrequency: '高',
            updateTime: '2024-04-08'
          },
          {
            date: '2024-04-10',
            questionBankId: 'T010',
            questionBankName: '眼科题库',
            questionType: '操作题',
            quantity: 15,
            difficultyLevel: '中等',
            usageFrequency: '高',
            updateTime: '2024-04-09'
          }
        ]
      }
      this.loading = false
      this.questionBankList = res.data
      this.pageparm.currentPage = this.questionInline.page
      this.pageparm.pageSize = this.questionInline.limit
      this.pageparm.total = res.count
      // 测试环境  模拟数据结束  
      /***
       *  正式环境环境 调用接口
       */
      surgeryRoom(parameter)
        .then(res => {
          this.loading = false
          if (res.success == false) {
            this.$message({
              type: 'info',
              message: res.msg
            })
          } else {
            this.questionBankList = res.data
            // 分页赋值
            this.pageparm.currentPage = this.questionInline.page
            this.pageparm.pageSize = this.questionInline.limit
            this.pageparm.total = res.count
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error('加载失败，请稍后再试！')
        })
    },
    // 分页插件事件
    callFather(parm) {
      this.questionInline.page = parm.currentPage
      this.questionInline.limit = parm.pageSize
      this.getdata(this.questionInline)
    },
    // 搜索事件
    search() {
      this.getdata(this.questionInline)
    },
    //添加、编辑
    questionEdit: function (index, row) {
      this.questionVisible = true
      if (row != undefined && row != 'undefined') {
        this.title = '编辑'
        this.question.roomNumber = row.roomNumber
        this.question.roomName = row.roomName
        this.question.bookingStatus = row.bookingStatus
        this.question.usageStatus = row.usageStatus
        this.question.surgeryType = row.surgeryType
        this.question.surgeryTime = row.surgeryTime
      } else {
        this.title = '添加'
        this.question.roomNumber = ''
        this.question.roomName = ''
        this.question.bookingStatus = ''
        this.question.usageStatus = ''
        this.question.surgeryType = ''
        this.question.surgeryTime = ''
      }
    },
    // 编辑、增加页面保存方法
    submitForm(editData) {
      this.$refs[editData].validate(valid => {
        if (valid) {
          deptSave(this.question)
            .then(res => {
              this.questionVisible = false
              this.loading = false
              if (res.success) {
                this.getdata(this.questionInline)
                this.$message({
                  type: 'success',
                  message: '题库保存成功！'
                })
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.questionVisible = false
              this.loading = false
              this.$message.error('题库保存失败，请稍后再试！')
            })
        } else {
          return false
        }
      })
    },
    // 删除题库
    deletequestion(index, row) {
      this.$confirm(`确定要删除题库吗?`, '删除题库', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          questionDelete(row.questionBankId)
            .then(res => {
              if (res.success) {
                this.$message({
                  type: 'success',
                  message: '题库已删除!'
                })
                this.getdata(this.questionInline)
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.loading = false
              this.$message.error('题库删除失败，请稍后再试！')
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 关闭编辑、增加弹框
    closeDialog() {
      this.questionVisible = false
    }
  }
}
</script>
<style scoped>
.surgery-search {
  margin-top: 20px;
}
</style>
 <!-- 题库统计分析 -->
<template>
  <div class="stbox">
    <!-- 面包屑导航 -->
    <div class="breadcrumb-title">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">题库管理</el-breadcrumb-item>
        <el-breadcrumb-item>题库统计分析</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="thinking-content">
      <!--不同难度题目数量 -->
      <div class="state-title">
        <div class="st-gbox" style="width:1200px;height: 250px;">
          <div class="cavasbox" ref="difficultychart"></div>
        </div>
      </div>
      <!-- 难度级别的题目占题库总数-->
      <div class="state-title">
        <div class="st-gbox" style="width:500px;height: 250px;">
          <div class="cavasbox" ref="typechart"></div>
        </div>
      </div>
        <!-- 难度级别的题目占题库总数-->
        <div class="state-title">
        <div class="st-gbox" style="width:1200px;height: 250px;">
          <div class="cavasbox" ref="scoreschart"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
import Chart from 'echarts'
export default {
  name: "welcome",
  data() {
    return {
      machineNo: '',
      type: 'day',
      scoresChart: null, // ECharts实例 
      difficultyData: [ // 不同难度题目的数量  
        {name: '简单', value: 50},  
        {name: '中等', value: 70},  
        {name: '困难', value: 30}  
      ],  
      questionTypeData: [ // 不同题型的数量  
        {name: '选择题', value: 80},  
        {name: '填空题', value: 40},  
        {name: '简答题', value: 60},  
        {name: '案例分析', value: 20}  
      ],
      difficultyQuestion: [ // 难度级别的题目数量  
        {name: '简单', value: 100},  
        {name: '中等', value: 200},  
        {name: '困难', value: 150},  
      ],  
      totalQuestions: 450 ,// 题库总数  
      scoresData: [ 
        { date: '2024-04-01', score: 85 },  
        { date: '2024-04-02', score: 92 },  
        { date: '2024-04-03', score: 88 },  
        { date: '2024-04-04', score: 95 },  
        { date: '2024-04-05', score: 89 },  
        { date: '2024-04-06', score: 91 },  
        { date: '2024-04-07', score: 90 },  
      ],  
    }
  },
  // 导入组件
  components: {
    // 点聚合组件
  },
  created() { },
  mounted() {
    this.getNumber()
    this.drawPieChart()
    this.initChart() 
  },
  methods: {
    // 不同难度题目数量
    getNumber() {
      let difficultyOption = {  
        title: {  
          text: '不同难度题目数量'  
        },  
        tooltip: {},  
        xAxis: {  
          data: this.difficultyData.map(item => item.name)  
        },  
        yAxis: {},  
        series: [{  
          name: '数量',  
          type: 'bar',  
          data: this.difficultyData.map(item => item.value)  
        }]  
      };  
      this.chart = Chart.init(this.$refs.difficultychart)
      this.chart.setOption(difficultyOption)
    },
    // 难度级别的题目占题库总数
    drawPieChart() {       
      // 计算每个难度级别的比例  
      const seriesData = this.difficultyData.map(item => {  
        const percentage = ((item.value / this.totalQuestions) * 100).toFixed(2);  
        return {name: item.name, value: percentage};  
      });  
      // 指定图表的配置项和数据  
      let  typeOption = {  
        title: {  
          text: '难度级别的题目占题库总数',  
          // subtext: '比例',  
          left: 'center'  
        },  
        tooltip: {  
          trigger: 'item'  
        },  
        legend: {  
          orient: 'vertical',  
          left: 'left',  
        },  
        series: [  
          {  
            name: '题目数量',  
            type: 'pie',  
            radius: ['50%', '70%'],  
            avoidLabelOverlap: false,  
            emphasis: {  
              label: {  
                show: true,  
                fontSize: '30',  
                fontWeight: 'bold'  
              }  
            },  
            labelLine: {  
              show: false  
            },  
            data: seriesData  
          }  
        ]  
      };  
      //显示图表
      this.chart = Chart.init(this.$refs.typechart)
      this.chart.setOption(typeOption)
    },
    initChart() {  
      // 指定图表的配置项和数据  
      const option = {  
        title: {  
          text: '考生得分随时间变化',  
        },  
        tooltip: {  
          trigger: 'axis',  
        },  
        xAxis: {  
          type: 'category',  
          data: this.scoresData.map(item => item.date),  
        },  
        yAxis: {  
          type: 'value',  
          min: 80, // 设置 Y 轴最小值  
          max: 100, // 设置 Y 轴最大值  
        },  
        series: [  
          {  
            data: this.scoresData.map(item => item.score),  
            type: 'line',  
          },  
        ],  
      };  
        // 初始化 
        this.scoresChart = Chart.init(this.$refs.scoreschart);  
      this.scoresChart.setOption(option); 
      // 窗口大小变化时调整图表大小  
      window.addEventListener('resize', this.scoresChart.resize);   
    }, 
    beforeDestroy() {  
    // 组件销毁前，清除窗口大小变化事件监听  
    window.removeEventListener('resize', this.scoresChart.resize);  
    // 销毁
    if (this.scoresChart) {  
      this.scoresChart.dispose();  
    }  
  },  
  }
};
</script>
<style> 
.stbox {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
}
.stsearch {
  text-align: center;
}
.text-c {
  text-align: center;
}
.st-gbox {
  background-color: #fff;
  margin-top: 20px;
  border-radius: 5px;
  height: 30vh;
  box-sizing: border-box;
  padding: 10px;
}
.cavasbox {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
}
.canvas{
  width: 100%;
  height: 100%;
}
.paybox {
  width: 100%;
  background-color: #fff;
  box-sizing: border-box;
  border-radius: 5px;
  margin-top: 20px;
  height: 32vh;
}
.breadcrumb-title {
  margin-top: 10px;
  margin-bottom: 10px;
}
</style>
<!-- 题库关联资源 -->
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: 'bank/bank' }">题库管理</el-breadcrumb-item>
      <el-breadcrumb-item>题库关联资源</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="questionBankInline" class="booking-search">
      <el-form-item label="搜索：">
        <el-input size="small" v-model="questionBankInline.questionBankID" placeholder="题库ID"></el-input>
      </el-form-item>
      <el-form-item label="">
        <el-input size="small" v-model="questionBankInline.questionBankName" placeholder="题库名称"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table size="small" :data="resourceList" highlight-current-row v-loading="loading" border
      element-loading-text="加载中" style="width: 95.2%;">
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column align="center" prop="questionBankID" label="题库ID" width="200">
      </el-table-column>
      <el-table-column align="center" prop="questionBankName" label="题库名称" width="200">
      </el-table-column>
      <el-table-column align="center" prop="relatedResourceID" label="关联资源ID" width="100">
      </el-table-column>
      <el-table-column align="center" prop="relatedResourceType" label="关联资源类型" width="200">
      </el-table-column>
      <el-table-column align="center" prop="resourceLink" label="资源链接" width="300">
        <template slot-scope="scope">
          <div><a :href="scope.row.resourceLink" target="_blank">{{ scope.row.resourceLink }}</a></div>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="remarks" label="备注" width="200">
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
  </div>
</template>
<script>
import { resource, } from '../../api/basisMG'
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      title: '',
      questionBankInline: {
        page: 1,
        limit: 10,
        questionBankID: '',
        questionBankName: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      resourceList: [], //资源数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  created() {
    this.getdata(this.questionBankInline)
  },
  methods: {
    // 获取数据列表
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      let res = {
        code: 0,
        msg: null,
        count: 17,
        data: [
          {
            date: '2024-04-01',
            questionBankID: 'T001',
            questionBankName: 'Internal Medicine Question Bank',
            relatedResourceID: 'R001',
            relatedResourceType: 'Documentation',
            resourceLink: 'https://example.com/resources/docs/internal_medicine.pdf',
            remarks: 'Core question bank'
          },
          {
            date: '2024-04-02',
            questionBankID: 'T002',
            questionBankName: 'Surgery Question Bank',
            relatedResourceID: 'R002',
            relatedResourceType: 'Video Tutorial',
            resourceLink: 'https://example.com/resources/videos/surgery_tutorials.mp4',
            remarks: 'Includes surgical demonstrations'
          },
          {
            date: '2024-04-03',
            questionBankID: 'T003',
            questionBankName: 'Obstetrics & Gynecology Question Bank',
            relatedResourceID: 'R003',
            relatedResourceType: 'Case Analysis',
            resourceLink: 'https://example.com/resources/cases/obstetrics_gynecology.docx',
            remarks: 'Typical cases'
          },
          {
            date: '2024-04-04',
            questionBankID: 'T004',
            questionBankName: 'Pediatrics Question Bank',
            relatedResourceID: 'R004',
            relatedResourceType: 'Image Gallery',
            resourceLink: 'https://example.com/resources/images/pediatrics_symptoms.zip',
            remarks: 'Disease symptoms images'
          },
          {
            date: '2024-04-05',
            questionBankID: 'T005',
            questionBankName: 'Emergency Medicine Question Bank',
            relatedResourceID: 'R005',
            relatedResourceType: 'Mock Test',
            resourceLink: 'https://example.com/resources/quizzes/emergency_medicine.xlsx',
            remarks: 'Past exam questions'
          },
          {
            date: '2024-04-06',
            questionBankID: 'T006',
            questionBankName: 'Medical Imaging Question Bank',
            relatedResourceID: 'R006',
            relatedResourceType: 'Medical Imaging Materials',
            resourceLink: 'https://example.com/resources/images/medical_imaging.jpg',
            remarks: 'CT/MRI images'
          },
          {
            date: '2024-04-07',
            questionBankID: 'T007',
            questionBankName: 'Pharmacology Question Bank',
            relatedResourceID: 'R007',
            relatedResourceType: 'Drug Manuals',
            resourceLink: 'https://example.com/resources/docs/drug_manuals.pdf',
            remarks: 'Common drug information'
          },
          {
            date: '2024-04-08',
            questionBankID: 'T008',
            questionBankName: 'Pathology Question Bank',
            relatedResourceID: 'R008',
            relatedResourceType: 'Pathology Slide Images',
            resourceLink: 'https://example.com/resources/images/pathology_slides.png',
            remarks: 'Histology slides'
          },
          {
            date: '2024-04-09',
            questionBankID: 'T009',
            questionBankName: 'Nursing Question Bank',
            relatedResourceID: 'R009',
            relatedResourceType: 'Nursing Procedure Videos',
            resourceLink: 'https://example.com/resources/videos/nursing_procedures.mp4',
            remarks: 'Nursing procedure flows'
          },
          {
            date: '2024-04-10',
            questionBankID: 'T010',
            questionBankName: 'Psychology Question Bank',
            relatedResourceID: 'R010',
            relatedResourceType: 'Psychology Articles',
            resourceLink: 'https://example.com/resources/articles/psychology.html',
            remarks: 'Mental'
          }
        ]
      }
      this.loading = false
      this.resourceList = res.data
      this.pageparm.currentPage = this.questionBankInline.page
      this.pageparm.pageSize = this.questionBankInline.limit
      this.pageparm.total = res.count
      // 测试环境  模拟数据结束  
      /***
       *  正式环境环境 调用接口
       */
      resource(parameter)
        .then(res => {
          this.loading = false
          if (res.success == false) {
            this.$message({
              type: 'info',
              message: res.msg
            })
          } else {
            this.resourceList = res.data
            // 分页赋值
            this.pageparm.currentPage = this.questionBankInline.page
            this.pageparm.pageSize = this.questionBankInline.limit
            this.pageparm.total = res.count
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error('加载失败，请稍后再试！')
        })
    },
    // 分页插件事件
    callFather(parm) {
      this.questionBankInline.page = parm.currentPage
      this.questionBankInline.limit = parm.pageSize
      this.getdata(this.questionBankInline)
    },
    // 搜索事件
    search() {
      this.getdata(this.questionBankInline)
    },
  }
}
</script>
<!-- 考核管理 -->
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: 'assessment/assessmentList' }">考核管理</el-breadcrumb-item>
      <el-breadcrumb-item>考核管理</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 搜索筛选 -->
    <el-form :inline="true" :model="assessmentInline" class="surgery-search">
      <el-form-item label="搜索：">
        <el-input size="small" v-model="assessmentInline.roomNumber" placeholder="输入考核名称"></el-input>
      </el-form-item>
      <el-form-item label="">
        <el-input size="small" v-model="assessmentInline.deptNo" placeholder="请输入考核类型"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button size="small" type="primary" @click="search">搜索</el-button>
        <el-button size="small" type="primary" @click="assessmentEdit()">新增</el-button>
      </el-form-item>
    </el-form>
    <!--列表-->
    <el-table size="small" :data="assessmentList" highlight-current-row v-loading="loading" border
      element-loading-text="拼命加载中" style="width: 95.2%;">
      <el-table-column align="center" type="selection" width="60">
      </el-table-column>
      <el-table-column align="center" prop="name" label="考核名称" width="200">
      </el-table-column>
      <el-table-column align="center" prop="type" label="考核类型" width="200">
      </el-table-column>
      <el-table-column align="center" prop="date" label="考核日期" width="100">
      </el-table-column>
      <el-table-column align="center" prop="startTime" label="开始时间" width="100">
      </el-table-column>
      <el-table-column align="center" prop="endTime" label="结束时间" width="200">
      </el-table-column>
      <el-table-column align="center" prop="participantCount" label="参与人数" width="200">
      </el-table-column>
      <el-table-column align="center" prop="status" label="考核状态" width="260">
      </el-table-column>
      <el-table-column align="center" label="操作" width="240">
        <template slot-scope="scope">
          <el-button size="mini" @click="assessmentEdit(scope.$index, scope.row)">查看</el-button>
          <el-button size="mini" type="danger" @click="deleteAssessment(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
    <!-- 编辑界面 -->
    <el-dialog :title="title" :visible.sync="assessmentVisible" width="30%" @click="closeDialog">
      <el-form label-width="120px" :model="assessment" :rules="assessmentRules" ref="assessment">
        <el-form-item label="考核名称" prop="name">
          <el-input size="small" v-model="assessment.name" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="考核类型" prop="type">
          <el-input size="small" v-model="assessment.type" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="考核日期" prop="date">
          <el-input size="small" v-model="assessment.date" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="开始时间" prop="startTime">
          <el-input size="small" v-model="assessment.startTime" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="结束时间" prop="endTime">
          <el-input size="small" v-model="assessment.endTime" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="参与人数" prop="participantCount">
          <el-input size="small" v-model="assessment.participantCount" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
        <el-form-item label="考核状态" prop="status">
          <el-input size="small" v-model="assessment.status" auto-complete="off" placeholder="请输入"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="closeDialog">取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title"
          @click="submitForm('assessment')">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { surgeryRoom, assessmentSave, assessmentDelete } from '../../api/basisMG'
import Pagination from '../../components/Pagination'
export default {
  data() {
    return {
      loading: false, //是显示加载
      assessmentVisible: false, //控制编辑页面显示与隐藏
      title: '查看',
      assessment: {
        id: '',
        name: '',
        type: '',
        date: '',
        startTime: '',
        endTime: '',
        participantCount: '',
        status: '',
        token: localStorage.getItem('logintoken')
      },
      // assessmentRules表单验证
      assessmentRules: {
        assessmentBankName: [
          { required: true, message: '请输入考核名称', trigger: 'blur' }
        ],
        assessmentBankId: [{ required: true, message: '请输入考核类型', trigger: 'blur' }]
      },
      assessmentInline: {
        page: 1,
        limit: 10,
        token: localStorage.getItem('logintoken')
      },
      // 删除部门
      seletedata: {
        ids: '',
        token: localStorage.getItem('logintoken')
      },
      userparm: [], //搜索权限
      assessmentList: [], //数据
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 10,
        total: 10
      }
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  created() {
    this.getdata(this.assessmentInline)
  },
  methods: {
    // 获取数据列表
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      let res = {
        code: 0,
        msg: null,
        count: 36,
        data: [
          {
            id: 1,
            name: '内科临床思维考核',
            type: '案例分析',
            date: '2024-03-15',
            startTime: '09:00',
            endTime: '10:30',
            participantCount: 45,
            status: '已完成'
          },
          {
            id: 2,
            name: '外科临床思维考核',
            type: '实操考核',
            date: '2024-03-20',
            startTime: '14:00',
            endTime: '16:00',
            participantCount: 40,
            status: '已完成'
          },
          {
            id: 3,
            name: '妇产科临床思维考核',
            type: '选择题',
            date: '2024-03-25',
            startTime: '08:30',
            endTime: '10:00',
            participantCount: 38,
            status: '已完成'
          },
          {
            id: 4,
            name: '儿科临床思维考核',
            type: '简答题',
            date: '2024-04-01',
            startTime: '13:30',
            endTime: '14:45',
            participantCount: 43,
            status: '已完成'
          },
          {
            id: 5,
            name: '神经科临床思维考核',
            type: '病例分析',
            date: '2024-04-05',
            startTime: '09:15',
            endTime: '11:00',
            participantCount: 56,
            status: '已完成'
          },
          {
            id: 6,
            name: '眼科临床思维考核',
            type: '判断题',
            date: '2024-04-10',
            startTime: '10:00',
            endTime: '11:00',
            participantCount: 36,
            status: '已完成'
          },
          {
            id: 7,
            name: '耳鼻喉科临床思维考核',
            type: '填空题',
            date: '2024-04-15',
            startTime: '14:15',
            endTime: '15:45',
            participantCount: 40,
            status: '已完成'
          },
          {
            id: 8,
            name: '皮肤科临床思维考核',
            type: '问诊模拟',
            date: '2024-04-20',
            startTime: '08:45',
            endTime: '10:15',
            participantCount: 35,
            status: '进行中'
          },
          {
            id: 9,
            name: '肿瘤科临床思维考核',
            type: '综合题',
            date: '2024-04-25',
            startTime: '11:30',
            endTime: '13:00',
            participantCount: 48,
            status: '未开始'
          },
          {
            id: 10,
            name: '精神科临床思维考核',
            type: '综合题',
            date: '2024-04-29',
            startTime: '13:00',
            endTime: '14:30',
            participantCount: 53,
            status: '未开始'
          },
        ]
      }
      this.loading = false
      this.assessmentList = res.data
      this.pageparm.currentPage = this.assessmentInline.page
      this.pageparm.pageSize = this.assessmentInline.limit
      this.pageparm.total = res.count
      // 测试环境  模拟数据结束  
      /***
       *  正式环境环境 调用接口
       */
      surgeryRoom(parameter)
        .then(res => {
          this.loading = false
          if (res.success == false) {
            this.$message({
              type: 'info',
              message: res.msg
            })
          } else {
            this.assessmentList = res.data
            // 分页赋值
            this.pageparm.currentPage = this.assessmentInline.page
            this.pageparm.pageSize = this.assessmentInline.limit
            this.pageparm.total = res.count
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error('加载失败，请稍后再试！')
        })
    },
    // 分页插件事件
    callFather(parm) {
      this.assessmentInline.page = parm.currentPage
      this.assessmentInline.limit = parm.pageSize
      this.getdata(this.assessmentInline)
    },
    // 搜索事件
    search() {
      this.getdata(this.assessmentInline)
    },
    //添加、编辑
    assessmentEdit: function (index, row) {
      this.assessmentVisible = true
      if (row != undefined && row != 'undefined') {
        this.title = '查看'
        this.assessment.name = row.name
        this.assessment.type = row.type
        this.assessment.date = row.date
        this.assessment.startTime = row.startTime
        this.assessment.endTime = row.endTime
        this.assessment.participantCount = row.participantCount
        this.assessment.status = row.status
      } else {
        this.title = '添加'
        this.assessment.name = ''
        this.assessment.type = ''
        this.assessment.date = ''
        this.assessment.startTime = ''
        this.assessment.endTime = ''
        this.assessment.surgeryTime = ''
        this.assessment.status =''
      }
    },
    // 保存
    submitForm(editData) {
      this.$refs[editData].validate(valid => {
        if (valid) {
          assessmentSave(this.assessment)
            .then(res => {
              this.assessmentVisible = false
              this.loading = false
              if (res.success) {
                this.getdata(this.assessmentInline)
                this.$message({
                  type: 'success',
                  message: '考核保存成功！'
                })
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.assessmentVisible = false
              this.loading = false
              this.$message.error('考核保存失败，请稍后再试！')
            })
        } else {
          return false
        }
      })
    },
    // 删除
    deleteAssessment(index, row) {
      this.$confirm(`确定要删除吗?`, '删除', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          assessmentDelete(row.assessmentBankId)
            .then(res => {
              if (res.success) {
                this.$message({
                  type: 'success',
                  message: '已删除!'
                })
                this.getdata(this.assessmentInline)
              } else {
                this.$message({
                  type: 'info',
                  message: res.msg
                })
              }
            })
            .catch(err => {
              this.loading = false
              this.$message.error('删除失败，请稍后再试！')
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    // 关闭编辑、增加弹框
    closeDialog() {
      this.assessmentVisible = false
    }
  }
}
</script>
<!-- 考核结果分析 -->
<template>
  <div class="stbox">
    <!-- 面包屑导航 -->
    <div class="breadcrumb-title">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: 'assessment/assessmentList' }">考核管理</el-breadcrumb-item>
        <el-breadcrumb-item>考核结果分析</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="thinking-content">
      <!--考核分数 -->
      <div class="state-title">
        <div class="st-gbox" style="width:1200px;height: 450px;">
          <div class="cavasbox" ref="difficultychart"></div>
        </div>
      </div>
      <!-- 考核通过率-->
      <div class="state-title">
        <div class="st-gbox" style="width:500px;height: 300px;">
          <div class="cavasbox" ref="typechart"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
import Chart from 'echarts'
import { color } from 'echarts/lib/theme/light';
export default {
  name: "welcome",
  data() {
    return {
      machineNo: '',
      type: 'day',
      scoreData: [
        { name: '内科临床思维考核', value: 80 },
        { name: '外科临床思维考核', value: 82 },
        { name: '妇产科临床思维考核', value: 78 },
        { name: '儿科临床思维考核', value: 90 },
        { name: '神经科临床思维考核', value: 88 },
      ],
    }
  },
  // 导入组件
  components: {
  },
  created() { },
  mounted() {
    this.getscoreData()
    this.drawPieChart()
  },
  // 里面的函数只有调用才会执行
  methods: {
    // 考核分数柱状图
    getscoreData() {
      let difficultyOption = {
        title: {
          text: '考核分数柱状图'
        },
        tooltip: {},
        xAxis: {
          data: this.scoreData.map(item => item.name),
        },
        yAxis: {
          axisLine: {
          },
        },
        series: [{
          name: '数量',
          type: 'bar',
          data: this.scoreData.map(item => item.value),
          itemStyle: {
            normal: {
              color: "#FFb6ce",
              lineStyle: {
                color: "#FFb6ce",
              }
            }
          }
        }]
      };
      this.chart = Chart.init(this.$refs.difficultychart)
      this.chart.setOption(difficultyOption)
    },
    // 难度级别的题目占题库总数
    drawPieChart() {
      // 计算每个难度级别的比例  
      // 指定图表的配置项和数据  
      let typeOption = {
        title: {
          text: '考核通过率',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left',
        },
        series: [
          {
            name: '考核通过率统计',
            type: 'pie',
            radius: '55%',
            center: ['50%', '50%'],
            data: [
              { name: '通过', value: '80' ,itemStyle: {color: 'rgba(75, 192, 192, 1)'}},
              { name: '未通过', value: "10",itemStyle: {color: 'rgba(255, 99, 132, 1)'} },
              { name: '优秀', value: "10",itemStyle: {color: 'rgba(153, 102, 255, 1)'} },
            ].sort(function (a, b) { return a.value - b.value; }),
            roseType: 'radius',
          }
        ],
      };
      //显示图表
      this.chart = Chart.init(this.$refs.typechart)
      this.chart.setOption(typeOption)
    },
  }
};
</script>
<!-- 培训资源管理 -->
<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: 'trainResources/trainResources' }">培训资源管理</el-breadcrumb-item>
      <el-breadcrumb-item>培训资源管理</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="resource-replay-list">
      <div v-for="(resource, index) in resources" :key="index" class="resource-card">
        <div class="card-header">
          <h3>{{ resource.name }}</h3>
          <p>{{ resource.date }}</p>
        </div>
        <div class="card-content">
          <p>{{ resource.description }}</p>
        </div>
        <div class="card-footer">
          <button class="play-button" @click="resourceCheck(resource)">查看</button>
          <button class="delete-button" @click="deleteresource(index, resource)">删除</button>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { resourceList, deptSave, deptDelete } from '../../api/userMG'
export default {
  data() {
    return {
      resourceInline: {
        page: 1,
        limit: 10,
        varLable: '',
        varName: '',
        token: localStorage.getItem('logintoken')
      },
      resources: [], //数据列表
      // 分页参数
      pageparm: {
        currentPage: 1,
        pageSize: 12,
        total: 12
      },
      resource: {
        title: '',
        date: 'date',
        description: ''
      }
    }
  },
  created() {
    this.getdata(this.resourceInline)
  },
  methods: {
    // 获取列表
    getdata(parameter) {
      this.loading = true
      // 模拟数据开始
      let res = {
        code: 0,
        msg: null,
        count: 20,
        data: [
          {
            id:1,
            name: '临床案例库',
            description: '更新收录最新的临床案例，包含多种疾病类型，供学员进行实战演练，提升临床思维能力。',
            date: '2024-03-15'
          },
          {
            id:2,
            name: '模拟诊疗系统升级',
            description: '对模拟诊疗系统进行功能优化和升级，增加更多真实的临床场景和诊疗工具，提高模拟诊疗的真实性。',
            date: '2024-03-20'
          },
          {
            id:3,
            name: '专家在线讲座',
            description: '邀请知名临床专家进行在线讲座，分享临床经验和最新研究成果，与学员进行互动交流。',
            date: '2024-03-25'
          },
          {
            id:4,
            name: '临床指南更新',
            description: '根据最新研究进展和临床实践，更新临床指南和规范，确保学员掌握最新的临床知识和技术。',
            date: '2024-04-01'
          },
          {
            id:5,
            name: '在线学习平台维护',
            description: '对在线学习平台进行定期维护和更新，确保平台的稳定性和学习资源的丰富性。',
            date: '2024-04-05'
          },
          {
            id:6,
            name: '互动讨论区优化',
            description: '优化互动讨论区的功能和界面，提高学员之间的交流效率和体验。',
            date: '2024-04-10'
          },
          {
            id:7,
            name: '临床技能操作视频录制',
            description: '录制新的临床技能操作视频，包括最新的手术技术和操作方法，供学员学习和参考。',
            date: '2024-04-15'
          },
          {
            id:8,
            name: '实时反馈系统升级',
            description: '对实时反馈系统进行升级，提高反馈的准确性和及时性，帮助学员更好地调整临床思维策略。',
            date: '2024-04-20'
          },
          {
            id:9,
            name: '临床知识题库更新',
            description: '更新临床知识题库，增加新的题目和考点，确保学员能够全面掌握临床知识。',
            date: '2024-04-25'
          },
        ]
      }
      this.loading = false
      this.resources = res.data
      this.pageparm.currentPage = this.resourceInline.page
      this.pageparm.pageSize = this.resourceInline.limit
      this.pageparm.total = res.count
      //测试环境使用模拟数据
      //正式环境 正式环境环境 调用接口
      resourceList(parameter)
        .then(res => {
          this.loading = false
          if (res.success == false) {
            this.$message({
              type: 'info',
              message: res.msg
            })
          } else {
            this.resources = res.data
            // 分页赋值
            this.pageparm.currentPage = this.resourceInline.page
            this.pageparm.pageSize = this.resourceInline.limit
            this.pageparm.total = res.count
          }
        })
        .catch(err => {
          this.loading = false
          this.$message.error('数据加载失败，请稍后再试！')
        })
    },
    //
    resourceAdd() {
      // 创建资源对象  
      const resource = {
        title: title,
        date: date,
        description: description || 'No description provided.'
      };
      // 将资源对象添加到数组中  
      resources.push(resource);
    },
    deleteresource(index, item) {
      // 首先，检查 index
      if (index < 0 || index >= resources.length) {
        console.error('Invalid index for resource deletion.');
        return;
      }
      if (resources[index] !== item) {
        console.error('The item to delete does not match the item at the given index.');
        return;
      }  
      axios.delete(`/api/resources/${item.id}`)
        .then(response => {
          if (response.success === 1) {
            // 从本地数组中移除资源  
            resources.splice(index, 1);
            //重新渲染资源列表  
            updateresourceListUI();
          } {
            alert('删除出错了')
          }
        })
        .catch(error => {
          alert('删除出错了')
        });
    },
    // 删除后被调用  
    updateresourceListUI() {
      this.$store.commit('updateresources', resources);
    },
    //查看资源
    resourceCheck(resource) {
      //触发查看方法
      this.$bus.$emit('resourceCheck', resource);
    }
  }
}
</script>
<style scoped>
.resource-replay-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
}
.resource-card {
  margin: 10px;
  padding: 20px;
  background-color: #f5f5f5;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  width: 300px;
  max-width: 100%;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header h3 {
  margin: 0;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}
button {
  padding: 5px 10px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}
button:hover {
  background-color: #eee;
}
.play-button {
  background-color: rgb(6, 131, 12);
  color: #ffffff;
  font-size: 16px;
}
.delete-button {
  background-color: rgb(247, 67, 13);
  color: #ffffff;
  font-size: 16px;
}
</style>
